from re import sub
n = int(input())
digits = len(str(n))
result = 0
for i in range(digits):
sub_result = 9 ** i
sub_n = n // (10 ** i)
remainder_n = n % (10 ** i)
should_be_reduce = False
temp_n = n
for j in range(i):
if (temp_n % 10 != 9):
should_be_reduce = True
temp_n /= 10
while (sub_n > 0):
if (should_be_reduce):
if (sub_n % 10 == 0):
sub_result *= 9
else:
should_be_reduce = False
sub_result *= max(1, ((sub_n % 10) - 1))
else:
sub_result *= ((sub_n % 10))
sub_n //= 10
if (sub_result > result):
result = sub_result
print(result)
#include <bits/stdc++.h>
using namespace std;
int solve(int n)
{
if(n<10)
{
return max(1, n);
}
return max(n%10*solve(n/10), solve(n/10-1)*9);
}
int main()
{
int n;
cin>>n;
cout<<solve(n)<<endl;
}
1463B - Find The Array | 1538C - Number of Pairs |
621B - Wet Shark and Bishops | 476B - Dreamoon and WiFi |
152C - Pocket Book | 1681D - Required Length |
1725D - Deducing Sortability | 1501A - Alexey and Train |
721B - Passwords | 1263D - Secret Passwords |
1371B - Magical Calendar | 1726E - Almost Perfect |
1360C - Similar Pairs | 900A - Find Extra One |
1093D - Beautiful Graph | 748A - Santa Claus and a Place in a Class |
1511B - GCD Length | 676B - Pyramid of Glasses |
597A - Divisibility | 1632A - ABC |
1619D - New Year's Problem | 242B - Big Segment |
938A - Word Correction | 159C - String Manipulation 10 |
258A - Little Elephant and Bits | 1536C - Diluc and Kaeya |
1428C - ABBB | 1557A - Ezzat and Two Subsequences |
255A - Greg's Workout | 1059A - Cashier |